
// 组队界面点击提升队长  {"序列":4}

// @ts-ignore
export async function execute(client_id,message_json) {
    let index = message_json["序列"];
    if (index === undefined || index-1 <= 0 || index-1 > 4) {
        ClientUtils.send_basic_prompt(client_id, "还没有选择玩家");
        return;
    }

    
    let login_characters = G.Characters.get_current_login_characters(client_id);
    if (!login_characters["队长"]) {
        ClientUtils.send_basic_prompt(client_id, "不是队长没有权限操作");
        return;
    }
    index = index - 1;

    if (index === 0) {
        ClientUtils.send_basic_prompt(client_id, "你已经是队长请勿重复操作");
        return;
    }
    
    let team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);
    if (team_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队伍已不存在");
        return;
    }
    let target = team_data["成员"][index];
    if (target === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队员不存在");
        return;
    }
    let res = G.TeamUtils.update_team_leader(login_characters["队伍"],index);
    if (res === 0){
        ClientUtils.send_basic_prompt(client_id, "#R设置队长失败");
        return;
    }
    let team_member = G.TeamUtils.get_team_member(login_characters["队伍"],index);
    console.info(team_member)
    ClientUtils.send_basic_prompt(client_id, `已将#G${team_member["名称"]}#提升为队长`);

}
